<%@page import="com.cd.util.DBUtil,java.sql.*,com.cd.model.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'info.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
  
	<%if(session.getAttribute("loginFlag")==null){
  response.sendRedirect("login.jsp");
  }else if(Integer.valueOf(session.getAttribute("loginFlag").toString())!=1){
  response.sendRedirect("login.jsp");
  } %>
  

</head>

<body>
<%
  	User user2 = new User(); 
	String username = "";
	if(session.getAttribute("username")!=null){
	username = session.getAttribute("username").toString();}
	DBUtil dataBase = new DBUtil();
	ResultSet rs = dataBase.query("SELECT * FROM user where username = '"+username+"'");
	/* ResultSet rs = null;
	dataBase.getConnection().createStatement().execute("SELECT * FROM user WHERE username = '"+u+"'") */
	if(rs.next()){
	user2.setUsername(rs.getString(2));
	System.out.println("username: "+rs.getString(2));
	user2.setPassword(rs.getString(3));
	user2.setNickname(rs.getString(4));
	user2.setEmail(rs.getString(5));
	user2.setNumber(rs.getString(6));
	user2.setSex(rs.getString(7));
	user2.setDate(rs.getTimestamp(8));
	}else{
	System.out.println("搜索不到数据");
	}
	System.out.println(session.getAttribute("username"));
	System.out.println(user2.toString());
	dataBase.closeService();
	if(rs.isClosed()==false){
	rs.close();
	}
	%>

	<center>
	
	<table>
	<tr><td>用户名<td><td><%=user2.getUsername() %><td></tr>
	<tr><td>密码<td><td><%=user2.getPassword() %><td></tr>
	<tr><td>昵称<td><td><%=user2.getNickname() %><td></tr>
	<tr><td>邮箱<td><td><%=user2.getEmail() %><td></tr>
	<tr><td>手机号码<td><td><%=user2.getNumber() %><td></tr>
	<tr><td>性别<td><td><%=user2.getSex() %><td></tr>
	<tr><td>注册时间<td><td><%=user2.getDate() %><td></tr>
	</table>
	<a href="LogoutServlet">登出</a>
	</center>
</body>
</html>
